<template>
  <div class="" style="margin-top: 20px">
    <el-form ref="formRef" label-width="150px" :model="form" :rules="rules">
      <el-form-item label="设备类型" prop="DeviceType">
        <el-select v-model="form.DeviceType" placeholder="请选择设备类型">
          <template v-for="(item, index) in typeData">
            <el-option :label="item" :value="item" />
          </template>
        </el-select>
      </el-form-item>
    </el-form>
    <div class="pay-button-group">
      <el-button type="primary" @click="handleSubmit">下一步</el-button>
    </div>
  </div>
</template>

<script>
  import { GetAllDeviceType } from '@/api/equipment'

  export default {
    data() {
      return {
        formRef: null,
        form: {
          DeviceType: [],
        },
        rules: {
          DeviceType: [
            { required: true, message: '请选择设备类型', trigger: 'blur' },
          ],
        },
        typeData: [],
      }
    },
    mounted() {
      GetAllDeviceType({ Index: 0, Count: 10 }).then((res) => {
        this.typeData = res.DeviceTypes
      })
    },
    methods: {
      handleSubmit1() {
        this.$emit('change-step', 0)
      },
      handleSubmit() {
        this.$refs['formRef'].validate((valid) => {
          if (valid) {
            let step = 1
            switch (this.form.DeviceType) {
              case '机床设备':
                step = 1
                break
              case '料库设备':
                step = 2
                break
              case '运输设备':
                step = 3
                break
              case '机床设备':
                step = 4
                break
            }
            step = 1
            this.$emit('change-step', step, this.form)
          } else {
            this.loading = false
          }
        })
      },
    },
  }
</script>

<style lang="scss" scoped>
  .pay-button-group {
    display: block;
    margin: 20px auto;
    text-align: center;
  }
</style>
